wayland: don't pass in width and height to create_shm_pool
authorRay Strode <rstrode@redhat.com>
Wed, 20 Jan 2016 17:35:44 +0000 (12:35 -0500)
committerRay Strode <rstrode@redhat.com>
Wed, 20 Jan 2016 19:29:15 +0000 (14:29 -0500)
create_shm_pool doesn't need the width or height, it just needs
the total size.  By passing it in, we're requiring it to redo
stride calculation unnecessarily.

This commit drops the width and height parameters and makes the
function just take the total size directly.

https://bugzilla.gnome.org/show_bug.cgi?id=760897

gdk/wayland/gdkdisplay-wayland.c

index bf3c20c8a918b5d8fc0f82b0b82ac841053cd40e..7c19a5c6cba1b07843d6b947293beddc3b11fd7d 100644 (file)
@@ -924,14 +924,13 @@ static const struct wl_buffer_listener buffer_listener = {
 
 static struct wl_shm_pool *
 create_shm_pool (struct wl_shm  *shm,
-                 int             width,
-                 int             height,
+                 int             size,
                  size_t         *buf_length,
                  void          **data_out)
 {
   char filename[] = "/tmp/wayland-shm-XXXXXX";
   struct wl_shm_pool *pool;
-  int fd, size, stride;
+  int fd;
   void *data;
 
   fd = mkstemp (filename);
@@ -943,8 +942,6 @@ create_shm_pool (struct wl_shm  *shm,
     }
   unlink (filename);
 
-  stride = width * 4;
-  size = stride * height;
   if (ftruncate (fd, size) < 0)
     {
       g_critical (G_STRLOC ": Truncating temporary file failed: %s",
@@ -1008,7 +1005,7 @@ _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *display,
   stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width*scale);
 
   data->pool = create_shm_pool (display->shm,
-                                width*scale, height*scale,
+                                height*scale*stride,
                                 &data->buf_length,
                                 &data->buf);